package t4tools.etodo.model;

import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import t4tools.etodo.enums.TreeViewElementType;

public abstract class AbstractTreeElement implements TreeElement {
	private String name;
	private TreeViewElementType type;

	public AbstractTreeElement(String name, TreeViewElementType type) {
		this.type = type;
		this.name = name;
	}

	@Override
	public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
		return null;
	}

	@Override
	public TreeViewElementType getType() {
		return type;
	}

	public String getName() {
		return name;
	}

	@Override
	public Image getIcon() {
		String iconKey = null;
		switch (getType()) {
		case CATEGORY:
			iconKey = ISharedImages.IMG_OBJ_FOLDER;
			break;
		case TODO:
			iconKey = ISharedImages.IMG_OBJ_ELEMENT;
			break;
		default:
			break;
		}
		if (iconKey != null) {
			return PlatformUI.getWorkbench().getSharedImages().getImage(iconKey);
		}
		return null;
	}
}
